/**
 * @(#)com.framework.web.sys.service.LogService
 *
 * Copyright (c) 2014-2018 上海天跃科技有限公司
 *
 * DESC:
 *
 */
package com.framework.web.sys.service;

import com.framework.web.sys.domain.Log;
import com.framework.web.sys.repository.LogRepository;
import com.framework.web.sys.repository.specifications.LogSpecs;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.data.domain.Page;
import org.springframework.data.domain.PageRequest;
import org.springframework.stereotype.Service;

/**
 * @author fusf
 * @version 1.0  2016/1/8
 */
@Service
public class LogService {

    @Autowired
    private LogRepository logRepository;

    /**
     * 新增或者保存
     * @param log
     * @return
     */
    public Log save(Log log) {
        return logRepository.save(log);
    }

    /**
     * 删除
     * @param id
     */
    public void  delete(String id) {
        logRepository.delete(id);
    }
    /**
     * 根据id查询
     * @param id
     * @return
     */
    public Log findById(String id) {
        return logRepository.findOne(id);
    }


    /**
     * 分页查找
     * @param log
     * @param pr
     * @return
     */
    public Page<Log> getPageList(Log log, PageRequest pr) {
        Page<Log> totalList = logRepository.findAll(
                LogSpecs.LikeLogType(log), pr);
        return totalList;
    }



}
